﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lamex.mSA.Common
{
    public class GetSapData
    {
        /// <summary>
        /// 取得SAP返回的数据表
        /// </summary>
        /// <param name="table">MES传SAP的表</param>
        /// <param name="strError">返回错误信息</param>
        /// <returns></returns>
        public static DataTable ReturnSapTable(DataTable table, out string strError)
        {

            //using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在从SAP下载数据......", new Size(400, 80)))
            //{
            string sapError = "";
            string sapConnectName = "";
            string DBName = Lamex.Common.Loginer.CurrentUser.DBName;
            if (DBName.Contains("正式") || DBName.Contains("Product"))
                sapConnectName = "LXP";
            else
                sapConnectName = "LXQ";
            Lamex.Common.SAPHelper sAPHelper = new Lamex.Common.SAPHelper();
            //从SAP获取数据
            DataTable sapTable = new DataTable();
            sapTable = sAPHelper.GetSAPDataTable(table,
                "I_MATS",
                Common.GetTable.GetSAP_TABLE(),
                "ZBAPI_GET_MAT_VOL_WEI",
                Common.GetTable.GetSAP_LIST()
                , sapConnectName
                , out strError);
            sapError = strError;
            return sapTable;
            //}
        }
    }
}
